<template>
  <div class="merchant alltable">
    <div class="tabbar">
      <div class="let">  
         <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.startday"
          value = 'yyyy-MM-dd'
          placeholder="请选择开始日期"
          style="width: 130px"
        ></DatePicker>&nbsp;
        <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.endday"
          placeholder="请选择结束日期"
          style="width: 130px"
        ></DatePicker>&nbsp;     
        <Select v-model="data_axios.paykind" placeholder="支付方式" class="service" style="width:130px">
          <Option v-for="item in paykindlist" :value="item.mid" :key="item.cname">{{ item.cname }}</Option>
        </Select>&nbsp;
        <Select v-model="data_axios.type" placeholder="身份" class="service" style="width:130px">
          <Option v-for="item in typelist" :value="item.mid" :key="item.cname">{{ item.cname }}</Option>
        </Select>&nbsp;       
        <Input
          prefix="ios-search"          
          v-model.trim="data_axios.selectinfo"
          placeholder="请输入关键字 身份证/订单号 "
          style="width: 200px"
        />
        <Button class="btn_default" @click="search">
          <Icon type="ios-search" size="17" class="icon_wy"/>查询
        </Button>
      </div>
      <!--   <div class='rit'>               
                <Button @click="add_merchant"><Icon type="ios-add-circle-outline" size="17" class="icon_wy"/>添加员工</Button>
      </div>-->
    </div>
    <div class="tabble">
      <div>
        <Table
          :columns="columns"
          :loading="loading"
          height="560"
          :data="data.datas"
          class="sel_table"
        ></Table>
      </div>
    </div>

    <div class="tab_pages">
      <Page
        :total="data.allCount"
        :page-size="data_axios.pagesize"
        :current.sync="data_axios.pagenumber"
        show-total
        @on-change="merchant_data"
      ></Page>
    </div>
  </div>
</template>
<script>
import { setAdmin, setToken, getAdmin } from "../../../utils/auth.js";
import { selectTopUpList } from "../../../apis/api_system.js";
import filter from './../../../filters/filter';
export default {
  name: "rec_record",
  data() {
    return {
      userId: "",
      model1: "",
      value: "",
      data: {
        allCount: 0,
        currPage: 1,
        datas: [],        
      },
      data_axios: {
        startday: "",
        endday: "",
        pagesize: 10,
        pagenumber: 1,        
        selectinfo: "",
        type: "",
        paykind: ""
      },
      loading: false,
      Mnamelist: [],
      //  1微信 2支付宝 3其他
      paykindlist: [
        {
          mid: 1,
          cname: "微信"
        },
        {
          mid: 2,
          cname: "支付宝"
        },
        {
          mid: 3,
          cname: "其他"
        }
      ],
      //   1 2已退款
      typelist: [
        {
          mid: 1,
          cname: "学生"
        },
        {
          mid: 2,
          cname: "老师"
        }
      ],

      columns: [
        {
          title: "序号",
          key: "name",
          type: "index",
          width: 50
        },
        {
          title: "金额",
          key: "paymentamt",
          width: 100,          
        },
        {
          title: "身份",
          key: "type",
          width: 100,
          render: (h, params) => {
            const row = params.row;
            const text = row.type === 1 ? "学生" : row.type === 1 ? "老师" : "Fail";
            return <span>{text}</span>;
          }
        },
        {
          title: "充值人",
          key: "operatename",
          width: 100,
        },
        {
          title: "支付时间",
          key: "paydate",
          //  width: 100
        },
        {
          title: "支付方式",
          key: "paykindname",   
           width: 100,       
        },
        {
          title: "充值人身份证",
          key: "identity"
        },
        {
          title: "订单号 ",
          key: "outtradeno"
        },
        {
          title: "一卡通订单号",
          key: "cartoonorderid"
        },
        {
          title: "第三方订单号 ",
          key: "apipayid",
          //  width: 50
        },
         {
          title: "充值说明",
          key: "body",
          tooltip: true
          //  width: 50
        },
      ],
      
    };
  },
  
  mounted() {    
    let info = getAdmin();
    this.userId = info.id;
    // console.log(this.userId);
    // this.selectMname();
    this.selectTopUpList(this.data_axios);
  },
  methods: {  
    //   获取充值记录
    selectTopUpList(info) {   
      this.loading = true;      
       if(this.data_axios.startday!=''){
          this.data_axios.startday =  filter.FileterDate(this.data_axios.startday);
       }
       if(this.data_axios.endday!=''){
          this.data_axios.endday =  filter.FileterDate(this.data_axios.endday);
       }      
      let data = JSON.stringify({
        requestString: JSON.stringify(info),
        userId: this.userId,
        fullname: "充值记录"
      });
      selectTopUpList(data)
        .then(({ returnString, code, disp ,count}) => { 
          this.loading = false;
          if (code == 200) {   
            this.data.datas = JSON.parse(returnString);
            this.data.allCount = count;           
          } else {            
            this.$Message.warning(disp);
          }
        })
        .catch(err => {});
    },   
    //分页改变
    merchant_data() {
       this.selectTopUpList(this.data_axios);
    },
    //   搜索
    search() {
      this.data_axios.pagenumber=1;
      this.selectTopUpList(this.data_axios);
    },
    
  }
};
</script>